package com.protocols.sctp.m3ua.sccp.tcap.camel;

import java.io.Serializable;

import com.protocols.BCDNumber;
import com.protocols.GeneralProtocolData;
import com.protocols.OctaveInteger;
import com.protocols.ProtoOperations;
import com.protocols.ProtocolStackException;
import com.protocols.sctp.m3ua.sccp.tcap.TcapBegin;
import com.protocols.sctp.m3ua.sccp.tcap.TcapConstructor;
import com.protocols.sctp.m3ua.sccp.tcap.TcapPrimitiveUnitByteArray;
import com.protocols.sctp.m3ua.sccp.tcap.TcapPrimitiveUnitNumber;

public class CamelInvoke implements GeneralProtocolData,Serializable{

	protected TcapConstructor Invoke = new TcapConstructor(0xa1);
	protected TcapPrimitiveUnitNumber InvokeID = new TcapPrimitiveUnitNumber(0x02);
	protected TcapPrimitiveUnitNumber LinkedID = new TcapPrimitiveUnitNumber(0x80);
	protected TcapPrimitiveUnitNumber OpCodeLocal = new TcapPrimitiveUnitNumber(0x02);
	protected TcapPrimitiveUnitNumber OpCodeGlobal = new TcapPrimitiveUnitNumber(0x06);
	
	public CamelInvoke() {
		
		Invoke.addElement(InvokeID);
		Invoke.addElement(LinkedID);
		Invoke.addElement(OpCodeLocal);
		Invoke.addElement(OpCodeGlobal);	
	}
	
	public byte [] getByteArray(){	
		return Invoke.getByteArray();
		

	}	

	public long getInvokeID() {
		return InvokeID.getTagValue();
	}

	public void setInvokeID(long invokeID) {
		InvokeID.setTagValue(invokeID);
	}	
	
	public long getLinkedID() {
		return LinkedID.getTagValue();
	}

	public void setLinkedID(long linkedID) {
		LinkedID.setTagValue(linkedID);
	}
	
	public long getOpCode(Boolean local) {
		return local?OpCodeLocal.getTagValue():OpCodeGlobal.getTagValue();
	}

	public void setOpCode(long opCode,Boolean local ) {
		if(local)
		{
			OpCodeLocal.setTagValue(opCode);
			OpCodeGlobal.setVisible(false);
		}
		else{
			OpCodeGlobal.setTagValue(opCode);
			OpCodeLocal.setVisible(false);
		}
	}

	@Override
	public int getLength() {
		return getByteArray().length;
	}

	@Override
	public byte[] decode(byte[] input) throws ProtocolStackException {
		
		return Invoke.decode(input);
	}
	
	
}
